import {IModel} from "./IModel";
import {setValidator} from "../decorator/setValidator";
import {validatorEnum} from "../validator/validatorEnum";
import {ArticleTypeEnum} from "./ArticleTypeEnum";
/**
 * Created by ybjaa on 2017/6/7.
 */


export class ms_article implements IModel{

    public ID:number=0;


    protected title:string="";

    public weight:number=0;

    protected content:string="";

    protected type:string="";


    get Title():string{
        return decodeURIComponent(this.title);
    }

    set Title(value:string){
        this.title=encodeURIComponent(value);
    }


    get Content():string{
        return decodeURIComponent(this.content);
    }

    set Content(value:string){
        this.content=encodeURIComponent(value);
    }


    public setType(type:ArticleTypeEnum){
        this.type=ArticleTypeEnum[type];
    }

    public clone():ms_article
    {
        let model=new ms_article();

        model.ID=this.ID;
        model.title=this.title;
        model.weight=this.weight;
        model.content=this.content;
        return model;

    }



    public copyFrom(model:ms_article):ms_article
    {
        this.ID=model.ID;
        this.title=model.title;
        this.weight=model.weight;
        this.content=model.content;
        return this;
    }


}